﻿using System;
using System.Collections.Generic;

namespace FortuneCookie.EPiServer.SearchAndReplace
{

    /// <summary>
    /// Search and replace entity class
    /// </summary>
    public sealed class SearchAndReplace : EntityBase
    {

        #region Members

        private string _startPage;
        private DateTime _created;
        private string _createdBy;
        private string _find;
        private string _replace;
        private bool _matchCase;
        private bool _updateDynamicProperties;
        private bool _searchWithinWords;
        private bool _startPageOnly;
        private bool _completed;

        #endregion Members

        #region Constructor

        /// <summary>
        /// Default constructor
        /// </summary>
        public SearchAndReplace()
        {
            _startPage = string.Empty;
            _createdBy = string.Empty;
            _find = string.Empty;
            _replace = string.Empty;
            Pages = new List<Page>();
            DynamicProperties = new List<DynamicProperty>();
            Errors = new List<Error>();
        }

        #endregion Constructor

        #region Properties

        /// <summary>
        /// Gets or sets the start page
        /// </summary>
        public string StartPage
        {
            get
            {
                return _startPage;
            }
            set
            {
                if (_startPage == value)
                    return;

                _startPage = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets the created date
        /// </summary>
        public DateTime Created
        {
            get
            {
                return _created;
            }
            set
            {
                if (_created == value)
                    return;

                _created = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets who created the search
        /// </summary>
        public string CreatedBy
        {
            get
            {
                return _createdBy;
            }
            set
            {
                if (_createdBy == value)
                    return;

                _createdBy = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets the text to find
        /// </summary>
        public string Find
        {
            get
            {
                return _find;
            }
            set
            {
                if (_find == value)
                    return;

                _find = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets the text to replace
        /// </summary>
        public string Replace
        {
            get
            {
                return _replace;
            }
            set
            {
                if (_replace == value)
                    return;

                _replace = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets whether case should be matched
        /// </summary>
        public bool MatchCase
        {
            get
            {
                return _matchCase;
            }
            set
            {
                if (_matchCase == value)
                    return;

                _matchCase = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets whether dynamic properties should be updated
        /// </summary>
        public bool UpdateDynamicProperties
        {
            get
            {
                return _updateDynamicProperties;
            }
            set
            {
                if (_updateDynamicProperties == value)
                    return;

                _updateDynamicProperties = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets whether text should be searched for within words
        /// </summary>
        public bool SearchWithinWords
        {
            get
            {
                return _searchWithinWords;
            }
            set
            {
                if (_searchWithinWords == value)
                    return;

                _searchWithinWords = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets whether the start page should only be searched
        /// </summary>
        public bool StartPageOnly
        {
            get
            {
                return _startPageOnly;
            }
            set
            {
                if (_startPageOnly == value)
                    return;

                _startPageOnly = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets whether the search and replace has been completed
        /// </summary>
        public bool Completed
        {
            get
            {
                return _completed;
            }
            set
            {
                if (_completed == value)
                    return;

                _completed = value;
                HasChanges = true;
            }
        }

        /// <summary>
        /// Gets or sets pages
        /// </summary>
        public List<Page> Pages { get; set; }

        /// <summary>
        /// Gets or sets dynamic properties
        /// </summary>
        public List<DynamicProperty> DynamicProperties { get; set; }

        /// <summary>
        /// Gets or sets errors
        /// </summary>
        public List<Error> Errors { get; set; }
        
        #endregion Properties

    }
}
